﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MND.Login
{
    class LoginScenario : Scenario
    {
        private Users.User user;

        public LoginScenario(Users.User u)
        {
            user = u;
            string fname = String.Format(@"./Login/Login_{0}.scenario", Language.LanguageManager.Instance.GetCurrentLangCode());
            Load(new System.IO.FileInfo(fname));
        }

        public override void Send(string s)
        {
            user.Send(s+Environment.NewLine);
        }

        protected override void SetFunctions()
        {
            lua.RegisterFunction("bookUsername", user, user.GetType().GetMethod("BookName"));
            lua.RegisterFunction("performRegistration", user, user.GetType().GetMethod("Register"));
            lua.RegisterFunction("performLogin", user, user.GetType().GetMethod("Login"));
            
            base.SetFunctions();
        }
    }
}
